<%--
  Created by IntelliJ IDEA.
  User: Administrator
  Date: 2022/9/24
  Time: 9:06
  To change this template use File | Settings | File Templates.
--%>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<%@taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<html>
<head>
    <title>学生展示</title>
    <!-- 注意：项目正式环境请勿引用该地址 -->
    <link rel="stylesheet" href="${pageContext.request.contextPath}/static/layui/css/layui.css" >
</head>
<body>
<script type="text/html" id="barDemo">
    <a class="layui-btn layui-btn-xs" lay-event="detail" >查看详情</a>
<%--    <a class="layui-btn layui-btn-danger layui-btn-xs" lay-event="del">删除</a>--%>

</script>

<script type="text/html" id="toolbarDemo">
    <div class="layui-btn-container">
        <button class="layui-btn layui-btn-sm" lay-event="addStu">添加</button>
        <button class="layui-btn layui-btn-sm" lay-event="getCheckData">获取选中行数据</button>
        <button class="layui-btn layui-btn-sm" lay-event="getData">获取当前页数据</button>
        <button class="layui-btn layui-btn-sm" lay-event="isAll">是否全选</button>
    </div>
</script>
<div id="recorddetail"  style="display: none">

    <table class="layui-hide" id="test1" lay-filter = "test1"></table>

</div>

<%--查询条件--%>
<form class="layui-form" action="">

    <div class="layui-inline">
        <label class="layui-form-label">用户名</label>
        <div class="layui-input-inline">
            <input type="text" name="username" placeholder="请输入用户名" autocomplete="off" class="layui-input">
        </div>
    </div>
    <div class="layui-inline">
        <label class="layui-form-label">状态</label>
        <div class="layui-input-block">
            <select name="status"  class="layui-select">
                <option value="">请选择...</option>
                <option value="1">启用</option>
                <option value="2">禁用</option>
            </select>
        </div>

    </div>

    <div class="layui-inline">
        <label class="layui-form-label">角色</label>
        <div class="layui-input-block">
            <select name="rid"   class="layui-select ridSelect">
                <option value="">请选择...</option>
                <%--                    <option value="1">启用</option>--%>
                <%--                    <option value="2">禁用</option>--%>
            </select>
        </div>

    </div>

    <div class="layui-inline">
        <div class="layui-input-inline">
            <button class="layui-btn" lay-submit lay-filter="formDemo">查询</button>
            <button type="reset" class="layui-btn layui-btn-primary">重置</button>
        </div>
    </div>
</form>
<table class="layui-hide" id="test" lay-filter = "test"></table>
<!-- 注意：项目正式环境请勿引用该地址 -->
<script src="${pageContext.request.contextPath}/static/layui/layui.js"></script>
<%--<script src="${pageContext.request.contextPath}/static/jquery-3.6.1.min.js"></script>--%>
<script>

        layui.use(['table','layer','form','jquery','tree'], function(){
            var tree = layui.tree;
            var table = layui.table;
            var layer = layui.layer;
            var form = layui.form;
             var $ = layui.jquery;
            var namestatus=true;



            table.render({
                // element  元素
                elem: '#test'
                ,page:true
                ,limit:8
                ,limits:[8,10,20,30]
                ,toolbar: '#toolbarDemo'
                ,url:'${pageContext.request.contextPath}/tFpaRecord' //  表格了里面所需要的数据就是一个list里面有很多的map、对象
                ,cellMinWidth: 80 //全局定义常规单元格的最小宽度，layui 2.2.1 新增
                ,cols: [[
                    {type: 'checkbox', fixed: 'left'}
                    ,{type:'numbers',title:'编号'}
                    // field 后面跟的内容  必须跟后台传过来的数据里面的map 的key保持一致
                    ,{field:'id', title: 'ID', sort: true}
                    ,{field:'username', title: '名字', sort: true}
                    ,{field:'tel', title: '电话', sort: true}
                    ,{field:'yqcode', title: '邀请码', sort: true}
                    ,{field:'createtime', title: '做题时间', sort: true}
                    ,{fixed: 'right', title:'操作', minWidth: 125, toolbar: '#barDemo'}
                ]]

            });



            // 工具栏事件
            table.on('toolbar(test)', function(obj){
                var uid = obj.config.uid;
                var checkStatus = table.checkStatus(uid);
                var othis = lay(this);
                switch(obj.event){
                    case 'getCheckData':
                        var data = checkStatus.data;
                        layer.alert(layui.util.escape(JSON.stringify(data)));
                        break;
                    case 'getData':
                        var getData = table.getData(id);
                        console.log(getData);
                        layer.alert(layui.util.escape(JSON.stringify(getData)));
                        break;
                    case 'isAll':
                        layer.msg(checkStatus.isAll ? '全选': '未全选')
                        break;
                    case 'addStu':
                        $("#saveUserForm")[0].reset();
                        $(".pass").css("display","block");
                        layer.open({
                            type: 1,
                            area: ['500px', '400px'],
                            offset: '100px',
                            content:$("#premissiontree"),

                        });
                        break;
                };
            });

            //触发单元格工具事件
            //监听行工具事件
            table.on('tool(test)', function(obj){
                var data = obj.data;
                //console.log(obj)
                if(obj.event === 'detail'){
                    layer.open({
                        type: 1,
                        area: ['800px', '600px'],
                        offset: '100px',
                        content:$("#recorddetail"),

                    });
                    table.render({
                        // element  元素
                        elem: '#test1'
                        ,page:true
                        ,limit:10
                        ,limits:[10,20,30]
                        ,url:'${pageContext.request.contextPath}/tFpaRecord/'+data.id //  表格了里面所需要的数据就是一个list里面有很多的map、对象
                        ,cellMinWidth: 80 //全局定义常规单元格的最小宽度，layui 2.2.1 新增
                        ,cols: [[

                            {type:'numbers',title:'编号'}
                            // field 后面跟的内容  必须跟后台传过来的数据里面的map 的key保持一致
                            ,{field:'username', title: '名字'}
                            ,{field:'fpano', title: '编号'}
                            ,{field:'fpasub', title: '题目'} //width 支持：数字、百分比和不填写。你还可以通过 minWidth 参数局部定义当前单元格的最小宽度，layui 2.2.1 新增
                            ,{field:'xxa', title: '选项A'}
                            ,{field:'xxb', title: '选项B'}
                            ,{field:'xxc', title: '选项C'}
                            ,{field:'xxd', title: '选项D'}
                            ,{field:'fpaanswer', title: '答案'}

                        ]]

                    });

                }


            });




        });




</script>

</body>
</html>
